﻿using B.S.Data.MES.API.Applications.AccountApplication.Command;
using B.S.Domain.Accounts;
using B.S.Infratrctrue;
using B.S.Requst;
using MediatR;
using Microsoft.EntityFrameworkCore;

namespace B.S.Data.MES.API.Applications.AccountApplication.CommandHandler
{
    public class OrcandSelectCommandHandler : IRequestHandler<OrcandSelectCommand, APIRequst<List<OrcanClass>>>
    {
        public OrcandSelectCommandHandler(IBaseRepository<OrcanClass> _orcanRepository)
        {
            OrcanRepository = _orcanRepository;
        }

        public IBaseRepository<OrcanClass> OrcanRepository { get; }

        public async Task<APIRequst<List<OrcanClass>>> Handle(OrcandSelectCommand request, CancellationToken cancellationToken)
        {
            return new APIRequst<List<OrcanClass>>
            {
                Code = RequstCode.成功,
                Msg = "",
                Data = await OrcanRepository.GetAll().ToListAsync()
            };
        }
    }
}
